<?php
namespace app\serverfund\logic;

use \app\manage\logic\BaseLogic;

/**
 * 资金借款日志的逻辑层
 * @author adv30 <adv30@126.com> 2017年6月21日16:57:31
 */
class FundBorrowLog extends BaseLogic
{
    protected $name = 'fund_borrow_log';
    protected $config = 'db_config_fund';
    private $fundBorrowLogModel = '\app\serverfund\model\FundBorrowLog';

    // 所有用户资金借款日志分页数据
    public function list(array $data): array
    {
        $where['status'] = 1;
        $res = $this->model($this->fundBorrowLogModel)
                    ->where($where)
                    ->order('id desc')
                    ->paginate($data['list_rows'], false, ['page'=>$data['page']])
                    ->toArray();
        return auto_return_page($res, '已找到用户资金借款日志', '没有用户资金借款日志');
    }
    // 获取某些user_ids的的资金借款日志(分页)
    public function listByUserIds(array $data): array
    {
        $where['status'] = 1;
        $where['user_id'] = ['IN', $data['user_ids']];
        $res = $this->model($this->fundBorrowLogModel)
                    ->where($where)
                    ->order('id desc')
                    ->paginate($data['list_rows'], false, ['page'=>$data['page']])
                    ->toArray();
        return auto_return_page($res, '已找到用户资金借款日志', '没有用户资金借款日志');
    }
    // 获取某个用户某个状态的资金借款日志分页数据
    public function listByUserType(array $data): array
    {
        $where['status'] = 1;
        $where['user_id'] = $data['user_id'];
        $where['refund_status'] = $data['refund_status'];

        $res = $this->model($this->fundBorrowLogModel)
                    ->where($where)
                    ->order('id desc')
                    ->paginate($data['list_rows'], false, ['page'=>$data['page']])
                    ->toArray();
        return auto_return_page($res, '已找到用户资金借款日志', '没有用户资金借款日志');
    }
}